package com.black.platform.position.service.biz.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.black.common.web.PageQuery;
import com.black.platform.position.mapper.PositionMapper;
import com.black.platform.position.po.Position;
import com.black.platform.position.service.biz.PositionService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;


@Service
public class PositionServiceImpl extends ServiceImpl<PositionMapper, Position> implements PositionService {


    @Override
    public IPage<Position> search(PageQuery<Position> searchVo) {
        Position queryData = searchVo.getQueryData();
        QueryWrapper<Position> query = new QueryWrapper<>();
        if (!StringUtils.isEmpty(queryData.getPositionName())) {
            query.eq("position_name", queryData.getPositionName());
        }
        if (!StringUtils.isEmpty(queryData.getValid())) {
            query.eq("valid", queryData.getValid());
        }
        query.orderByAsc("orders");
        return this.baseMapper.selectPage(searchVo.getPager(), query);
    }
}
